(function($){
    var txtUser = "Username";
    var txtPassword = "Password";

    $(document).ready(function(){
        $('#username').defaultvalue(txtUser);
        $('#password').defaultvalue(txtPassword);
        $('#form-login').submit(function(e){
            function formFalse(e, msg) {
                e.preventDefault();
                e.stopPropagation();
                $('.text-error').html(msg).effect('highlight');
                return false;
            }

            if($('#username').val() == "" || $('#username').val() == txtUser) {
                return formFalse(e, "Username harus diisi");
            }

            if($('#password').val() == "" || $('#password').val() == txtPassword) {
                return formFalse(e, "Password harus diisi");
            }
        });
    });
    
    $(window).load(function(){        
        $('#box-login').show().dialog({
            width: 'auto',
            resizable: false,
            draggable: false,
            closeOnEscape: false,
            beforeClose: function(event, ui) {
                event.preventDefault();
                event.stopPropagation();
                return false;
            },
            buttons: {
                "Login": function() {
                    $('#form-login').submit();
                }
            }
        });
    });
})(jQuery);